﻿using AiFrame.InterfaceLib.Data.Access.NHibernateAccess;
using NHibernate;

namespace AiFrame.Base.Core.Data.Access
{
    /// <summary>
    /// The default session manager.
    /// </summary>
    internal sealed class DefaultSessionManager: INHibernateSessionManager
    {
        private ISession _session;

        public ISession GetSession(INhibernateHelper databaseConnection)
        {
            _session = databaseConnection.SessionFactory.OpenSession();
            return _session;
        }

        public void CloseSession()
        {
            if (_session != null)
                _session.Close();
            
        }
    }
}
